#ifndef __JZ47_VAE_MAP__
#define __JZ47_VAE_MAP__

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

#define DEBUG_ENABLE

#include <dlog.h>
#include "dmmu.h"

// for mipsel tool.
#define LINUX_MULTICORE
#define __USE_GNU
#include <sched.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <pthread.h>

int  VAE_map(int type);
void VAE_unmap(int type);
void Lock_Vpu();
void UnLock_Vpu();

extern pthread_mutex_t VaeLock;
extern int VAECNT;
extern int tcsm_fd;

extern volatile unsigned char *vpu_base;
extern volatile unsigned char *gp0_base;
extern volatile unsigned char *jpgc_base;

extern volatile unsigned char *cpm_base;
extern volatile unsigned char *aux_base;
extern volatile unsigned char *sde_base;
extern volatile unsigned char *mc_base;
extern volatile unsigned char *vmau_base;
extern volatile unsigned char *dblk0_base;
extern volatile unsigned char *efe_base;
extern volatile unsigned char *tcsm1_base;
extern volatile unsigned char *sram_base;

#define cpu_write(reg, val) (*((volatile unsigned int *)(reg)) = (val))
#define cpu_read(reg)       (*((volatile unsigned int *)(reg)))

int vpu_reset();
int jz_flush_cache(unsigned int vaddr, unsigned int size);
int jz_flush_all();

#endif
